package com.zzyl.controller.manager;

import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertDataHandleDto;
import com.zzyl.dto.AlertDataPageQueryDto;
import com.zzyl.service.AlertDataService;
import com.zzyl.vo.AlertDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/alert-data")
@Api(tags = "报警数据相关接口")
public class AlertDataController {
    @Autowired
    private AlertDataService alertDataService;

    /**
     * 分页查询报警数据
     *
     * @param alertDataPageQueryDto 警报数据页面查询dto
     * @return {@code ResponseResult<PageBean<AlertDataVo>> }
     * @author YiSheep
     */
    @ApiOperation(value = "分页查询报警数据")
    @GetMapping("/pageQuery")
    public ResponseResult<PageBean<AlertDataVo>> pageQuery(AlertDataPageQueryDto alertDataPageQueryDto) {
        log.info("分页查询报警数据:{}", alertDataPageQueryDto);
        PageBean<AlertDataVo> pageBean = alertDataService.adminPageQuery(alertDataPageQueryDto);
        return ResponseResult.success(pageBean);
    }

    /**
     * 处理设备报警数据
     *
     * @param id                 报警数据id
     * @param alertDataHandleDto 处理报警数据dto
     * @return {@code ResponseResult<Void> }
     * @author YiSheep
     */
    @ApiOperation("处理设备报警数据")
    @PutMapping("/handleAlertData/{id}")
    public ResponseResult<Void> handleAlertData(@PathVariable Long id, @RequestBody AlertDataHandleDto alertDataHandleDto) {
        log.info("处理设备报警数据:id {} alertDataHandleDto {}", id, alertDataHandleDto);
        alertDataService.handleAlertData(id, alertDataHandleDto);
        return ResponseResult.success();
    }
}